<?

/**
 * PROPER FILE TRANSFER HANDLER			
 *
 * @package	Public
 */


if( !( $id = (int) $_GET[ "id" ]) || !$type = $DB->simplestring( $_GET[ "type" ]))
	error( 404 );


$File = new OBJECT( $type, $id );

$ext	= $File->get( "ext" )? $File->get( "ext" ): array_pop( explode( ".", $raw = $File->get( "raw" ))); 
$file	= $File->hasName()? $File->get( "name" ) . ".$ext" : $raw;


header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$file");
header("Content-Type: application/$ext");
header("Content-Transfer-Encoding: binary");

	readfile( ROOT . ACCOUNT ."/www/DB/media/$id.$ext" );

?>